<template>
	<view>
		<view>
			<uni-list style="width: 100%;">
				<uni-list-item 
				title="团队详情" 
				showArrow
				clickable 
				@click="goTeamInfomation(team.id)" />
				<uni-list-item
				title="报销单申请"
				showArrow
				clickable 
				@click="goTeamReimbursement(team.id)" />
			</uni-list>
		</view>
		<!-- 暂时只有团队owner才有权限查看以下菜单 -->
		<view style="margin-top: 30rpx;" v-if="team.owner == user.userId">
			<uni-list v-if="team.owner == user.userId">
				<uni-list-item
				title="参数设置"
				showArrow
				clickable 
				@click="goTeamConfig(team.id)" />
				<uni-list-item
				title="员工管理" 
				showArrow
				clickable 
				@click="goTeamemployee(team.id)" />
				<uni-list-item v-if="team.openControl == 'OPEN'"
				title="审核流程设置" 
				showArrow
				clickable 
				@click="goTeamAudit(team.id)" />
				<uni-list-item
				title="团队花费" 
				showArrow
				clickable 
				@click="goTeamCost(team.id)" />
			</uni-list>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {},
				team: {},
			}
		},
		onLoad(ev){
			this.getListById(ev.id);
		},
		onShow(){
			this.user = this.$dry.get("user");
		},
		methods: {
			getListById(id){
				var token = this.$dry.getToken();
				var data = [];
				if(token){
				    data = this.$request.run("getTeamById",token);
				    uni.request({
				    	url: data.url,
				    	method: data.method,
				    	header: data.header,
				    	data: {
							"id": id
						},
				    	success: data => {
							if(data.statusCode === 200) {
								this.team = data.data;
							}
						}
					})
				}
			},
			goTeamInfomation(id){
				uni.navigateTo({
					url: "team-information?id=" + id
				})
			},
			goTeamemployee(id){
				uni.navigateTo({
					url: "employee?id=" + id
				})
			},
			goTeamAudit(id){
				uni.navigateTo({
					url: "team-auditor?id=" + id
				})
			},
			goTeamReimbursement(teamId){
				uni.navigateTo({
					url: "../new/reimbursement-new-edit?teamId=" + teamId
				})
			},
			goTeamCost(id){
				uni.navigateTo({
					url: "team-cost-list?id=" + id
				})
			},
			goTeamConfig(teamId) {
				uni.navigateTo({
					url: "config?teamId=" + teamId
				})
			}
			
		}
	}
</script>

<style>

</style>
